//
//  PromotionTableViewCell.m
//  rrbi
//
//  Created by mac book on 2018/12/4.
//

#import "PromotionTableViewCell.h"

@interface PromotionTableViewCell ()


@property(nonatomic,strong) UILabel * titleLabel;
@property(nonatomic,strong) UIButton * deleteBtn;

@end


@implementation PromotionTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubviews];
    }
    
    return self;
}

#pragma mark -
-(void)createSubviews{
    
    
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = kFontNameSize(15);
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
    [self.contentView addSubview:self.titleLabel];
    
    
    self.deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.deleteBtn.backgroundColor = getColor(greenBackColor);
    [self.deleteBtn setTitleColor: [UIColor whiteColor] forState:UIControlStateNormal];
    [self.deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
    self.deleteBtn.layer.masksToBounds = YES;
    self.deleteBtn.layer.cornerRadius = 5.f;
    self.deleteBtn.titleLabel.font = kFontNameSize(14);
    [self.deleteBtn addTarget:self action:@selector(deleteBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.deleteBtn];
    
    
    
    
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).mas_offset(-10);
        make.height.mas_equalTo(25);
        make.width.mas_equalTo(60);
        
    }];
    
    
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.right.equalTo(self.deleteBtn.mas_left);
        make.left.equalTo(self.contentView).mas_offset(20);
    }];

    
    
}

-(void)setStoreModel:(StoreModel *)storeModel{
    
    _storeModel = storeModel;
    
    self.titleLabel.text = [NSString stringWithFormat:@"满%@元 减%@元",storeModel.man,storeModel.jian];

}

-(void)deleteBtnDidClick{
    
    if (self.promotionDeleteBtnBlock) {
        self.promotionDeleteBtnBlock();
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
